#pragma once

#ifndef _OGL_VIEW_CONTROL
#define _OGL_VIEW_CONTROL

#include "OGLIControl.h"
#include "OGLGlobals.h"

#include <gl/glew.h>
#include <gl/GLU.h>
#include <gl/glfw.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtx/matrix_operation.hpp>

#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>

class OGLViewControl : public OGLIControl
{
private :
	
	glm::vec3 defaultCamLoc, defaultCamDir, defaultCamOrient;
	float defaultFov, defaultAspectRatio, defaultRangeMin, defaultRangeMax;
	
	glm::vec3 camLoc, camDir, camOrient;
	float fov, aspectRatio, rangeMin, rangeMax;

	// Camera's spherical coordinates
	// r = radius, i.e. distance from center of schene
	// theta = ascension from "equator" of schene (inclination, latitude)
	// phi = rotation along sphere (azimuth, longitude)
	float r, theta, phi;	
	glm::mat4 P, V, PV;
	bool matChanged;

	void setDefaults(void);

public :
	OGLViewControl(void);
	~OGLViewControl(void);

	OGLResult StartControl(void);
	OGLResult StopControl(void);

	glm::mat4 GetPVMat(void);
	void FirstUpdate(void);

	virtual void KeyboardActionHandler(void);
	virtual void MouseActionHandler(void);
};

#endif